﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bibylon.BehafX.StateMachine.concept
{

    internal abstract class condition : node
    {
        /// <summary>
        /// @Copydoc - node::c'tor
        /// </summary>
        public condition(string name, int nid, node parent)
            : base(name, nid, parent)
        { 
        }

        /// <summary>
        /// @Copydoc - node::Category
        /// </summary>
        public override string Category
        {
            get { return "Condition"; }
        }


        /// <summary>
        /// ...
        /// </summary>
        public override List<node> Children
        {
            // we don;t let a condition block have any children.
            get { return null; }
            protected set { /** nothing */ }
        }

        /// <summary>
        /// Copydoc - node::execute
        /// </summary>
        internal /*virtual*/ override int execute(object agent, object any)
        {
            // throw new NotImplementedException();
            if (judgement(agent, any) == true)
                QueryStatus = Status.Successful;
            else
                QueryStatus = Status.Failed;

            return (int)QueryStatus;
        }

        /// <summary>
        /// evaluate the condition criteria
        /// </summary>
        public abstract bool judgement(object agent, object any);

    }
}
